var echartsTheme = 'macarons';
$(function(){
    sjzmapGo();
});

function sjzmapGo(){
    var myChart = echarts.init(document.getElementById('div_sjzmap'), echartsTheme);

    var sjzdata = [
        {name: '平山县',value:1 },{name: '灵寿县',value: 2 },
        {name: '行唐县',value: 3 },{name: '正定县',value: 4 },
        {name: '新乐市',value: 5 },{name: '新华区',value: 6 },
        {name: '鹿泉市',value: 7 },{name: '井陉矿区',value: 24 },
        {name: '井陉县',value: 9 },{name: '桥东区',value: 10},
        {name: '桥西区',value: 11 },{name: '裕华区',value: 12 },
        {name: '长安区',value: 13 },{name: '藁城市',value: 14 },
        {name: '无极县',value: 15 },{name: '深泽县',value: 16 },
        {name: '栾城县',value: 17 },{name: '元氏县',value: 18 },
        {name: '赞皇县',value: 19 },{name: '高邑县',value: 20 },
        {name: '赵县',value: 21 },{name: '晋州市',value: 22},
        {name: '辛集市',value: 23 }
    ];
    myChart.showLoading();

    $.get(ctx + '/static/js/echarts/examples/china-main-city/130100.json', function (geoJson) {

        myChart.hideLoading();

        echarts.registerMap('SJZ', geoJson);

        myChart.setOption(option = {
            title: {
                text: '石家庄市地图'
            },
            tooltip: {
                trigger: 'item',
                formatter: '{b}<br/>{c} (p / km2)'
            },
            toolbox: {
                show: true,
                orient: 'vertical',
                left: 'right',
                top: 'center',
                feature: {
                    dataView: {readOnly: false},
                    restore: {},
                    saveAsImage: {}
                }
            },
            visualMap: {
                min: 0,
                max: 25,
                text:['High','Low'],
                realtime: false,
                calculable: true,
                inRange: {
                    color: ['lightskyblue','yellow', 'orangered']
                }
            },
            series: [
                {
                    name: '石家庄市地图',
                    type: 'map',
                    mapType: 'SJZ', // 自定义扩展图表类型
                    itemStyle:{
                        normal:{label:{show:true}},
                        emphasis:{label:{show:true}}
                    },
                    data:sjzdata

                    // 自定义名称映射
                   /* nameMap: {
                        '': '平山县',
                        '': '灵寿县',
                        '': '行唐县',
                        '': '正定县',
                        '': '新乐市',
                        '': '新华区',
                        '': '鹿泉市',
                        '': '井陉矿区',
                        '': '井陉县',
                        '': '桥东区',
                        '': '桥西区',
                        '': '裕华区',
                        '': '长安区',
                        '': '藁城市',
                        '': '无极县',
                        '': '深泽县',
                        '': '栾城县',
                        '': '元氏县',
                        '': '赞皇县',
                        '': '高邑县',
                        '': '赵县',
                        '': '晋州市',
                        '':'辛集市'
                    }*/
                }
            ]
        });
    });

   // myChart.setOption(option);

}

/*
function randomData() {
    return Math.round(Math.random()*500);
}*/
